import request from "@/util/request";

/**
 * 创建订单
 */
export function createOrder(data: {
    storeId: string;
    remark?: string;
    itemList: Array<{
        paramValueIdList: number[];
        productId: number;
        quantity: number;
    }>;
}) {
    return request({
        url: '/order/createOrder',
        method: 'post',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
}

/**
 * 查询订单列表
 */
export function listOrder(params: {
    storeId: string;
    status: number;
    startTime: string;
    endTime: string;
    pageNum: number;
    pageSize: number;
}) {
    return request({
        url: '/order/listOrder',
        method: 'get',
        headers: {
            'token': localStorage.getItem('token')
        },
        params
    });
}

export function receiveOrder(orderId: number) {
    return request({
        url: '/order/receiveOrder',
        method: 'get',
        headers: {
            'token': localStorage.getItem('adminToken')
        },
        params: {
            orderId:orderId
        }
    });
}

export function finishMaking(orderId: number) {
    return request({
        url: '/order/finishMaking',
        method: 'get',
        headers: {
            'token': localStorage.getItem('adminToken')
        },
        params: {
            orderId:orderId
        }
    });
}

export function pay(orderId: number) {
    return request({
        url: '/order/pay',
        method: 'get',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            orderId:orderId
        }
    });
}

export function pick(orderId: number, pickCode: number) {
    return request({
        url: '/order/pick',
        method: 'get',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            orderId: orderId,
            pickCode: pickCode
        }
    });
}
